<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use App\Pool\Core\MySQL;
use App\Pool\Database\DbPool;
use App\Pool\Core\CoRedis;
use App\Pool\Redis\RedisPool;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }

    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        // MySQL 连接池
        $this->app->singleton('mysql_pool', function () {
            return new MySQL(new DbPool($this->app));
        });

        // Reids 连接池
        $this->app->singleton('redis_pool', function () {
            return new CoRedis(new RedisPool($this->app));
        });
    }
}
